<?php


namespace App\Logic\reservation;


use App\Server\ApiService;
use Illuminate\Support\Facades\Validator;
use function Composer\Autoload\includeFile;

class ValiDateSout
{
    public static function create(array $data)
    {
        // 定义验证规则
        $rules = [[
            'patient' => 'required',//密码不能为空
            'visit_card' => 'required',
            'user_id' => 'required',
            'doctor_id' => 'required',
            'id_card' => 'required',
            'phone' => 'required',
            'sub_office' => 'required',
            'sub_type' => 'required',
            'sub_price' => 'required',
            'sub_status' => 'required',
            'address' => 'required',
            'sub_time' => 'required',
            'visit_time' => 'required',
        ], [
            'patient.required' => '密码不能为空',
            'visit_card.required' => '就诊卡号不能为空',
            'user_id.required' => '用户id格式不正确',
            'doctor_id.required' => '医生ID格式不正确',
            'id_card.required' => '身份证号不能为空',
            'phone.required' => '手机号不能为空',
            'sub_office.required' => '挂号科室不能为空',
            'sub_price.required' => '挂号价钱不能为空',
            'sub_status.required' => '挂号状态不能为空',
            'address.required' => '住址不能为空',
            'sub_time.required' => '预约时间不能为空',
            'visit_time.required' => '创建时间不能为空',
        ]];

        // 执行验证
        $validator = Validator::make($data, $rules);
        if ($validator->fails())
        {

            // 验证失败，抛出异常或返回错误信息
            // 在这里你可以根据实际需求选择抛出异常或返回错误信息
            ApiService::fail('不能为空');
        }


        // 验证通过，继续执行其他逻辑...

        return $data;
    }
}
